#ifndef DIEITEM_H
#define DIEITEM_H

#include <QGraphicsRectItem>

class DieItem : public QGraphicsRectItem
{
public:
    enum DieType {
        Four = 4,
        Six = 6,
        Eight = 8,
        Ten = 10,
        Twelve = 12,
        Twenty = 20
    };

    DieItem(DieType dieType, QRectF rect, QGraphicsItem* parent = 0);
    ~DieItem() {}

    DieType dieType() const { return m_dieType; }
    DieItem* create();
    uint roll();
    uint lastRoll() const { return m_lastRoll; }

    QGraphicsItem* containerItem() { return m_containerItem; }
    void setContainerItem(QGraphicsItem* item) { m_containerItem = item; }

    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);

protected:
    virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);

private:
    DieType m_dieType;
    uint m_lastRoll;
    QGraphicsItem* m_containerItem;
};

#endif // DIEITEM_H

